package com.tommy.ddp.disposeHandler.special
{
	import com.tommy.ddp.GridDataManager;
	import com.tommy.ddp.MainManager;
	import com.tommy.ddp.box.DdpBox;
	import com.tommy.ddp.definition.BoxDisposeAnimationTime;
	import com.tommy.ddp.definition.DDPConfig;
	import com.tommy.ddp.manager.DisposeBoxManager;
	import com.tommy.ddp.swapHandle.SubDisposeVo;
	
	import flash.utils.setTimeout;

	/**
	 * 大糖果消除
	 * @author hongxuan
	 * 
	 */	
	public class DisposeBigBangHandler implements ISpecialDisposeHandler
	{
		private var box:DdpBox;
		private var _vect:Vector.<DdpBox>;
		
		public function DisposeBigBangHandler()
		{
		}
		
		public function dispose(vect:Vector.<DdpBox>,n:Number):void
		{
			_vect = vect;
			box = vect[0];
			
			MainManager.game.tips = "big bang……";
			setTimeout(_dispose,n);
		}
		private function _dispose():void
		{
			for each(var b:DdpBox in _vect)
			{
				b.dispose();
				GridDataManager.removeBox(b);
			}
			_vect = null;
			
			var vect:Vector.<DdpBox> = new Vector.<DdpBox>();
			
			var sX:uint = box.column - 1;
			var eX:uint = box.column + 1;
			//消Y
			for(var i:uint = sX;i<=eX;i++)
			{
				for(var j:uint = 0;j<DDPConfig.H_NUM;j++)
				{
					var box:DdpBox = GridDataManager.getBox(i,j);
					if(box)
					{
						vect.push(box);
					}
				}
			}
			
			var sY:uint = box.row - 1;
			var eY:uint = box.row + 1;
			//消X
			for(i = 0;i<DDPConfig.W_NUM;i++)
			{
				for(j = sY;j<=eY;j++)
				{
					box = GridDataManager.getBox(i,j);
					if(box)
					{
						vect.push(box);
					}
				}
			}
			
			var vo:SubDisposeVo = new SubDisposeVo();
			vo.vect = vect;
			
			DisposeBoxManager.disposeSubVo(vo);
		}
	}
}